export default {
	data() {
		return {
			loading: false,
			queryData: {
				page: 1,
				limit: 15
			},
			dataCount: 0,
			tableData: [],
			dataId: '',
			formDialog: false
		}
	},
	mounted() {
		this.queryTableData();
	},
	methods: {
		async queryTableData() {
			this.loading = true;
			await this.getTableData();
			this.loading = false;
		},

		handleOpenDialog(data) {
			this.dataId = !data ? '' : data.id;
			this.formDialog = true;
		},

		//删除数据
		handleDeleteFunction(params, name, title) {
			let that = this;
			let nameText = '';
			if (Array.isArray(name)) {
				name.forEach(item => {
					nameText += `<font color="#f00">【${item}】</font>`
				})
			} else {
				nameText = `<font color="#f00">【${name}】</font>`;
			}
			that.$confirm(`此操作将删除${title}${nameText}, 是否继续?`, '删除提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				dangerouslyUseHTMLString: true,
				type: 'warning',
				async beforeClose(action, instance, done) {
					if (action === 'confirm') {
						instance.confirmButtonLoading = true;
						await that.deleteDataRequest(params);
						instance.confirmButtonLoading = false;
						that.queryTableData();
						done();
					} else {
						done();
					}
				}
			}).catch(() => {});
		},
	}
}